import {Request, Response} from 'express';
import {get, middleware, Controller} from '../decorator';
import {isValidUser, isVIPUser, isAdminUser} from '../middleaware/middlewarefunc';

@Controller("/food")
class FoodController {

    @get("/showfood")
    @middleware(isAdminUser)
    @middleware(isVIPUser)
    @middleware(isValidUser)
    showFood(req: Request, res: Response): void {
        res.setHeader("Content-Type", "text/html; charset=utf-8")
        res.write("大混沌");
        res.write("一锅炖");
        res.end();
    }


    @get("/searchfood/:foodname/:price/:shopname")
    @middleware(isValidUser)
    searchFood(req: Request, res: Response): void {
        res.setHeader("Content-Type", "text/html; charset=utf-8")
        res.write(`foodname: ${req.params.foodname} \n`);
        res.write(`price: ${req.params.price} \n`);
        res.write(`shopname: ${req.params.shopname}`);
        res.end();
    }
}
